package com.yanqu.road.entity.activity.daomu.config;

import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.activity.daomu.DaoMuSkill;
import com.yanqu.road.entity.activity.daomu.enums.DaoMuNpcTypeEnum;
import com.yanqu.road.utils.RandomHelper;

import java.util.*;

@FieldTypeAnnotation(tableName = "t_s_activity_daomu_mission")
public class DaoMuMissionConfig {
    /**
     * 活动ID
     */
    private int activityId;

    /**
     * id
     */
    private int id;

    /**
     * 难度类型（1简单2普通3困难
     */
    private int floor;

    /**
     * 地图ID
     */
    private int map;

    /**
     * 章节名称
     */
    private String chapterName;

    /**
     * 章节描述
     */
    private String chapterDesc;

    /**
     * 关卡名称
     */
    private String name;

    /**
     * 小怪出现时间s
     */
    private String mobsAppearTime;

    /**
     * 小怪id
     */
    private String mobsId;

    /**
     * 小怪出现频率
     */
    private String mobsAppearFrequency;

    /**
     * 小怪特效id0无1boss3一大波
     */
    private String mobsEffects;

    /**
     * 特殊怪出现时间s
     */
    private String specialMobsAppearTime;

    /**
     * 特殊怪id
     */
    private String specialMobsId;

    /**
     * 特殊怪数量
     */
    private String specialMobsNum;

    /**
     * 特殊怪特效id0无1boss3一大波
     */
    private String specialMobsEffects;

    /**
     * bossid
     */
    private String bossId;

    /**
     * boss出现时间
     */
    private String bossAppearTime;

    /**
     * boss特效id0无1boss3一大波
     */
    private String bossEffects;

    /**
     * 悬赏怪物id
     */
    private String bountyMonster;

    /**
     * 悬赏奖励数值配置（物品id=数量;物品id=数量
     */
    private String specialBountyRewards;

    /**
     * 首通固定奖励数值配置物品id数量
     */
    private String specialRewards;

    /**
     * 悬赏奖励运营配置（物品id=数量;物品id=数量
     */
    private String bountyRewards;

    /**
     * 首通固定奖励运营配置物品id数量
     */
    private String rewards;

    /**
     * 需要藏品分
     */
    private int needFavoriteScore;

    /**
     * 通关收藏分
     */
    private int passFavoriteScore;

    /**
     * 悬赏奖励-数值配置-游戏道具
     */
    private String specialBountyGameRewards;

    /**
     * 首通奖励-数值配置-游戏道具
     */
    private String specialGameRewards;

    /**
     * 特色服专用字段-解锁参数
     */
    private String unlock;

    /**
     * 关卡新增击杀怪物上限数量-血脉使用
     */
    private int mobsNumMax;

    /**
     * 特色服专用字段-伙伴id
     */
    private int partnerId;

    /**
     * 特色服专用字段-属性参数
     */
    private String param;

    /**
     * 特色服专用字段-技能列表(技能id；最高等级)
     */
    private String skillList;


    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getMap() {
        return map;
    }

    public void setMap(int map) {
        this.map = map;
    }

    public String getChapterName() {
        return chapterName;
    }

    public void setChapterName(String chapterName) {
        this.chapterName = chapterName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMobsAppearTime() {
        return mobsAppearTime;
    }

    public void setMobsAppearTime(String mobsAppearTime) {
        this.mobsAppearTime = mobsAppearTime;
    }

    public String getMobsId() {
        return mobsId;
    }

    public int getPassFavoriteScore() {
        return passFavoriteScore;
    }

    public void setPassFavoriteScore(int passFavoriteScore) {
        this.passFavoriteScore = passFavoriteScore;
    }

    public void setMobsId(String mobsId) {
        this.mobsId = mobsId;
    }

    public String getMobsAppearFrequency() {
        return mobsAppearFrequency;
    }

    public void setMobsAppearFrequency(String mobsAppearFrequency) {
        this.mobsAppearFrequency = mobsAppearFrequency;
    }

    public String getMobsEffects() {
        return mobsEffects;
    }

    public void setMobsEffects(String mobsEffects) {
        this.mobsEffects = mobsEffects;
    }

    public String getSpecialMobsAppearTime() {
        return specialMobsAppearTime;
    }

    public void setSpecialMobsAppearTime(String specialMobsAppearTime) {
        this.specialMobsAppearTime = specialMobsAppearTime;
    }

    public String getSpecialMobsId() {
        return specialMobsId;
    }

    public void setSpecialMobsId(String specialMobsId) {
        this.specialMobsId = specialMobsId;
    }

    public String getSpecialMobsNum() {
        return specialMobsNum;
    }

    public void setSpecialMobsNum(String specialMobsNum) {
        this.specialMobsNum = specialMobsNum;
    }

    public String getSpecialMobsEffects() {
        return specialMobsEffects;
    }

    public void setSpecialMobsEffects(String specialMobsEffects) {
        this.specialMobsEffects = specialMobsEffects;
    }

    public String getBossId() {
        return bossId;
    }

    public void setBossId(String bossId) {
        this.bossId = bossId;
    }

    public String getBossAppearTime() {
        return bossAppearTime;
    }

    public void setBossAppearTime(String bossAppearTime) {
        this.bossAppearTime = bossAppearTime;
    }

    public String getBossEffects() {
        return bossEffects;
    }

    public void setBossEffects(String bossEffects) {
        this.bossEffects = bossEffects;
    }

    public String getChapterDesc() {
        return chapterDesc;
    }

    public void setChapterDesc(String chapterDesc) {
        this.chapterDesc = chapterDesc;
    }

    public void setRewards(String rewards) {
        this.rewards = rewards;
    }

    public String getRewards() {
        return rewards;
    }

    public String getBountyMonster() {
        return bountyMonster;
    }

    public void setBountyMonster(String bountyMonster) {
        this.bountyMonster = bountyMonster;
    }

    public String getSpecialBountyRewards() {
        return specialBountyRewards;
    }

    public void setSpecialBountyRewards(String specialBountyRewards) {
        this.specialBountyRewards = specialBountyRewards;
    }

    public String getSpecialRewards() {
        return specialRewards;
    }

    public void setSpecialRewards(String specialRewards) {
        this.specialRewards = specialRewards;
    }

    public String getBountyRewards() {
        return bountyRewards;
    }

    public void setBountyRewards(String bountyRewards) {
        this.bountyRewards = bountyRewards;
    }

    public int getNeedFavoriteScore() {
        return needFavoriteScore;
    }

    public void setNeedFavoriteScore(int needFavoriteScore) {
        this.needFavoriteScore = needFavoriteScore;
    }

    public int getFloor() {
        return floor;
    }

    public void setFloor(int floor) {
        this.floor = floor;
    }

    public String getSpecialBountyGameRewards() {
        return specialBountyGameRewards;
    }

    public void setSpecialBountyGameRewards(String specialBountyGameRewards) {
        this.specialBountyGameRewards = specialBountyGameRewards;
    }

    public String getSpecialGameRewards() {
        return specialGameRewards;
    }

    public void setSpecialGameRewards(String specialGameRewards) {
        this.specialGameRewards = specialGameRewards;
    }

    public String getUnlock() {
        return unlock;
    }

    public void setUnlock(String unlock) {
        this.unlock = unlock;
    }

    public int getPartnerId() {
        return partnerId;
    }

    public void setPartnerId(int partnerId) {
        this.partnerId = partnerId;
    }

    public String getParam() {
        return param;
    }

    public void setParam(String param) {
        this.param = param;
    }

    public String getSkillList() {
        return skillList;
    }

    public void setSkillList(String skillList) {
        this.skillList = skillList;
    }

    public int getMobsNumMax() {
        return mobsNumMax;
    }

    public void setMobsNumMax(int mobsNumMax) {
        this.mobsNumMax = mobsNumMax;
    }

    /**
     * 获取小怪npc下标
     * @param second 第几秒
     * @return
     */
    private int getMobsNpcIndex(int second) {
        String[] timeArr = this.getMobsAppearTime().split("\\|");
        int index = -1;
        for (int i = 0; i < timeArr.length; i++) {
            String timeStr = timeArr[i];
            int time = Integer.valueOf(timeStr);
            if (second >= time) {
                index = i;
            }
        }
        return index;
    }

    /**
     * 获取小怪NPC
     * @param second 第几秒
     * @return
     */
    public Map<String, Integer> getMobsNpc(int second) {
        if (Objects.equals(this.getMobsId(), "0")) {
            return null;
        }
        int index = this.getMobsNpcIndex(second);
        if (index < 0) {
            return null;
        }
        Map<String, Integer> result = new HashMap<>();
        //npc id
        String[] idArr = this.getMobsId().split("\\|");
        String idStr = idArr[index];
        int npcId =  Integer.parseInt(idStr);
        result.put("npcId", npcId);
        //生成频率
        String[] frequencyArr = this.getMobsAppearFrequency().split("\\|");
        String frequencyStr = frequencyArr[index];
        String numStr = frequencyStr.split(";")[0];
        int num = Integer.parseInt(numStr);
        result.put("num", num);
        return result;
    }

    /**
     * 获取特殊怪NPC
     * @param second
     * @return
     */
    public Map<String, Integer> getSpecialNpc(int second) {
        if (Objects.equals(this.getSpecialMobsAppearTime(), "0")) {
            return null;
        }
        String[] timeArr = this.getSpecialMobsAppearTime().split("\\|");
        int i = 0;
        for (String timeStr : timeArr) {
            String[] timeStrArr = timeStr.split(";");
            int time =  Integer.parseInt(timeStrArr[0]);
            if (time == second) {
                Map<String, Integer> result = new HashMap<>();
                //npcID
                String[] npcIdArr = this.getSpecialMobsId().split("\\|");
                String npcIdStr = npcIdArr[i];
                result.put("npcId", Integer.parseInt(npcIdStr));
                //数量
                String[] numArr = this.getSpecialMobsNum().split("\\|");
                String numStr = numArr[i];
                result.put("num", Integer.parseInt(numStr));
                //出现最大秒数
                result.put("endTime", Integer.valueOf(timeStrArr[1]));
                return result;
            }
            i++;
        }
        return null;
    }

    /**
     * 特殊怪第几秒出现
     * @return
     */
    public int getSpecialShowTime() {
        String[] timeArr = this.getSpecialMobsAppearTime().split("\\|");
        //随机第几秒
        RandomHelper randomHelper = new RandomHelper();
        return randomHelper.next(Integer.valueOf(timeArr[0]), Integer.valueOf(timeArr[1] + 1));
    }

    /**
     * 获取BOSS NPC
     * @param second
     * @return
     */
    public Integer getBossNpc(int second) {
        String[] timeArr = this.getBossAppearTime().split("\\|");
        int i = 0;
        for (String timeStr : timeArr) {
            int time =  Integer.parseInt(timeStr);
            if (time == second) {
                Map<String, Integer> result = new HashMap<>();
                //npcID
                String[] npcIdArr = this.getBossId().split("\\|");
                String npcIdStr = npcIdArr[i];
                return Integer.parseInt(npcIdStr);
            }
            i++;
        }
        return null;
    }
}
